using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace UserInterface.Misc
{
    public class OutputTools
    {
        private const string DateFormat = "dd MMMM yyyy";
        
        public static string HTMLEntities(string text)
        {
            return text
                .Replace("&", "&amp;")
                .Replace("<", "&lt;")
                .Replace(">", "&gt;")
                .Replace("\"", "&quot;");
        }

        public static string ConvertNewLinesToBreaks(string text)
        {
            return text.Replace("\n", "<br>");
        }

        public static string FormatDate(DateTime dateTime)
        {
            return dateTime.ToString(DateFormat);
        }

        public static string JSEscape(string input)
        {
            return input
                .Replace("'", "\\'")
                .Replace("\"", "\\\"");
        }
    }
}
